package com.lanchewuyou.user.driver.yancheui;

import android.app.Activity;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.lanchewuyou.user.driver.R;
import com.lanchewuyou.user.driver.layouts.YancheDialog;
import com.lanchewuyou.user.driver.modul.Config;

/**
 * 验车选择上传照片界面
 */
public class YanchePerPhotoActivity extends AppCompatActivity implements View.OnClickListener {

    private ImageButton yanchePerPhoBack;
    private RelativeLayout yancheRelaJia1, yancheRelaJia2, yancheRelaXing1, yancheRelaXing2, yancheRelaShen1, yancheRelaShen2;
    private Button yanchePerPhotoNext;
    private TextView yancheTextJia1, yancheTextJia2, yancheTextXing1, yancheTextXing2, yancheTextShen1, yancheTextShen2;
    private YancheDialog.Builder builder;
    private static String DRIVERID;

    private Toast toast = null;

    private void showTextToast(String msg) {
        if (toast == null) {
            toast = Toast.makeText(this, msg, Toast.LENGTH_SHORT);
        } else {
            toast.setText(msg);
        }
        toast.show();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_yanche_per_photo);
        SharedPreferences sharedPreferences = getSharedPreferences(Config.PASSWORD_PATH, Activity.MODE_PRIVATE);
        DRIVERID = sharedPreferences.getString("driverid", "");
        initViews();
    }

    private void initViews() {
        yanchePerPhoBack = (ImageButton) findViewById(R.id.yanche_per_photo_back);
        yanchePerPhoBack.setOnClickListener(this);
        yanchePerPhotoNext = (Button) findViewById(R.id.yanche_per_photo_next_btn);
        yanchePerPhotoNext.setOnClickListener(this);
        yancheRelaJia1 = (RelativeLayout) findViewById(R.id.yanche_per_photo_jiashiben1);
        yancheRelaJia1.setOnClickListener(this);
        yancheRelaJia2 = (RelativeLayout) findViewById(R.id.yanche_per_photo_jiashiben2);
        yancheRelaJia2.setOnClickListener(this);
        yancheRelaXing1 = (RelativeLayout) findViewById(R.id.yanche_per_photo_xingshizheng1);
        yancheRelaXing1.setOnClickListener(this);
        yancheRelaXing2 = (RelativeLayout) findViewById(R.id.yanche_per_photo_xingshizheng2);
        yancheRelaXing2.setOnClickListener(this);
        yancheRelaShen1 = (RelativeLayout) findViewById(R.id.yanche_per_photo_shenfenzheng1);
        yancheRelaShen1.setOnClickListener(this);
        yancheRelaShen2 = (RelativeLayout) findViewById(R.id.yanche_per_photo_shenfenzheng2);
        yancheRelaShen2.setOnClickListener(this);
        yancheTextJia1 = (TextView) findViewById(R.id.yanche_jia1_text);
        yancheTextJia2 = (TextView) findViewById(R.id.yanche_jia2_text);
        yancheTextXing1 = (TextView) findViewById(R.id.yanche_xing1_text);
        yancheTextXing2 = (TextView) findViewById(R.id.yanche_xing1_text);
        yancheTextShen1 = (TextView) findViewById(R.id.yanche_shen1_text);
        yancheTextShen2 = (TextView) findViewById(R.id.yanche_shen1_text);
        builder = new YancheDialog.Builder(this);
        builder.setMessage("点击确认开始导航");
        builder.setNegativeButton("确定", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        builder.setPositiveButton("取消", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.yanche_per_photo_back:
                finish();
                break;
            case R.id.yanche_per_photo_next_btn:
                builder.create().show();
                break;
            case R.id.yanche_per_photo_jiashiben1:

                break;
            case R.id.yanche_per_photo_jiashiben2:

                break;
            case R.id.yanche_per_photo_xingshizheng1:

                break;
            case R.id.yanche_per_photo_xingshizheng2:

                break;
            case R.id.yanche_per_photo_shenfenzheng1:

                break;
            case R.id.yanche_per_photo_shenfenzheng2:

                break;
            default:
                break;
        }
    }

    /**
     * 设定已上传和未上传文字状态
     *
     * @param textView
     * @param upload
     */
    private void setUpload(TextView textView, boolean upload) {
        if (upload) {
            textView.setText("已上传");
            textView.setTextColor(Color.parseColor("#ef6e6e"));
        } else {
            textView.setText("未上传");
            textView.setTextColor(Color.parseColor("#888888"));
        }

    }
}
